{if $item.fileTypes}
<div class="tabs{if $item.fieldId} local{else} global{/if}" id="tabs-{$item.fieldId|default:'global'}">
    <ul>
        {foreach from=$item.fileTypes key=fileTypeKey item=fileType}
        <li><a href="#tab-{$item.fieldId|default:'global'}-{$fileType.id}">{$fileType.title}</a></li>
        {/foreach}
    </ul>
    {foreach from=$item.fileTypes key=fileTypeKey item=fileType}
    <ul class="filesList {$fileType.template}" id="tab-{$item.fieldId|default:'global'}-{$fileType.id}">
        {foreach from=$item.files item=file key=fileKey}
            {if $file.fileType == $fileType.id}
                {include file='form/file/type/'|cat:$fileType.template|cat:'.tpl'}
            {/if}
        {/foreach}
        {if $item.fieldId}
        <script type="text/javascript">
            sortableInit('tab-{$item.fieldId|default:'global'}-{$fileType.id}');
        </script>
        {/if}
    </ul>
    <div style="clear: both;"></div>
    {/foreach}
</div>
{else}
    <ul class="filesList image">
        {foreach from=$item.files item=file key=fileKey}
            {include file='form/file/type/image.tpl'}
        {/foreach}
    </ul>
    <div class="upload-file-wraper" id="upload-file-wraper-{$item.fieldId|default:global}"></div>
{/if}
<div class="dialog" id="dialog-{$item.fieldId|default:'global'}"></div>
<script type="text/javascript">
    $('#tabs-'+{$item.fieldId|default:"'global'"}).tabs();
</script>